package app.beit.fintrack.service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import app.beit.fintrack.bean.summary.SummaryRepDataBean;
import app.beit.fintrack.dao.SummaryRepDao;
import app.beit.fintrack.entity.summary.SummaryRepData;
import app.beit.fintrack.service.convert.SummaryRepConvert;
import app.beit.fintrack.utils.enums.ESearchByStatus;

public class SummaryRepService {

	private final Logger log = Logger.getLogger(this.getClass());
	
	@Autowired
	private SummaryRepDao summaryRepDao;

	public List<SummaryRepDataBean> getDetailsByRepNo(final String hospitalCode, final Date fromDate,
			final Date toDate, final int start, final int end, final String authType) throws Exception {
		this.log.info("get details data from hospital");
		final List<SummaryRepData> entities = this.summaryRepDao.getDetailsByHospital(hospitalCode, fromDate, toDate, start, end, authType);
		if(entities != null && entities.size() > 0){
			return SummaryRepConvert.entityToBean(entities);
		}
		
		return null;
	}
	
	public BigDecimal getSumsActAmount(final String hospitalCode, final Date fromDate, final Date toDate, final String authType)throws Exception{
		return this.summaryRepDao.getSumsActAmount(hospitalCode, fromDate, toDate, authType);
	}
	
	public BigDecimal getSumsTotal(final String hospitalCode, final Date fromDate, final Date toDate, final String authType)throws Exception{
		return this.summaryRepDao.getSumsTotal(hospitalCode, fromDate, toDate, authType);
	}
	
	public BigDecimal getCountPerson(final String hospitalCode, final Date fromDate, final Date toDate, final ESearchByStatus status, final String authType)throws Exception{
		return this.summaryRepDao.getCountPerson(hospitalCode, fromDate, toDate, status, authType);
	}
	
}
